package org.example.demo.test.search.strategy.first;


import com.example.demo.test.AbstractStrategyRouter;
import com.example.demo.test.StrategyHandler;
import com.example.demo.test.parm.InClass;
import com.example.demo.test.parm.OutClass;
import com.example.demo.test.search.strategy.reveal.defau.DefaultStrategy;
import com.example.demo.test.search.strategy.reveal.notdefault.NotDefaultStrategy;
import lombok.extern.slf4j.Slf4j;
import org.omg.CORBA.PRIVATE_MEMBER;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class TitleSort extends AbstractStrategyRouter<InClass, OutClass> implements  StrategyHandler<InClass,OutClass>  {

    @Autowired
    private DefaultStrategy defaultStrategy;
    @Autowired
    private NotDefaultStrategy notDefaultStrategy;
    @Override
    public OutClass apply(InClass param) {
        //TODO 处理用户基础搜索逻辑，走兜底策略
        log.info("当前调用方位：{}",this.getClass().getName());
        return applyStrategy(param);
    }

    @Override
    protected StrategyMapper<InClass, OutClass> registerStrategyMapper() {
        return new StrategyMapper<InClass, OutClass>() {
            @Override
            public StrategyHandler<InClass, OutClass> get(InClass param) {
                if(param.getIsDefaultTimeType()){
                    return defaultStrategy;
                }else{
                    return notDefaultStrategy;
                }
            }
        };
    }
}
